<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            var divs=document.querySelectorAll("div");//集合
            for(var i=0;i<divs.length;i++){//0  1   2    3
                divs[i].onclick=function(){
                   console.log(this.innerHTML);
                };
            }

        };
    </script>
</head>
<body>
    <div>div01</div>
    <div>div02</div>
    <div>div03</div>
</body>
</html>